package br.livro.android.cap5;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class ExemploVisualizarContato extends Activity implements OnClickListener {

	private EditText txtNum;
	private Button btnVer;
	
	@Override
	public void onCreate(Bundle icicle){
		super.onCreate(icicle);
		setContentView(R.layout.layout_contato);
	
		this.txtNum = (EditText) findViewById(R.id.txtNum);
		this.btnVer = (Button) findViewById(R.id.btnContato);
		this.btnVer.setOnClickListener(this);
	}
	
	@Override
	public void onClick(View v) {
		//Visualizar o contato
		Uri uri = Uri.parse("content://com.android.contacts/contacts/"+Integer.parseInt(this.txtNum.getText().toString()));
		//Cria a intent
		Intent it = new Intent(Intent.ACTION_VIEW,uri);
		//Envia a mensagem ao sistema operacional
		startActivity(it);
		
	}

}
